/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package vek.Objects;

import vek.ObjectCreation.ObjectCreator;
import java.util.ArrayList;
import vek.XML.parsedObjects.ParsedComercial;

/**
 * @see POI
 * @author Christian, Michal og Jakob (Hold 1, gruppe 2)
 */
public abstract class POIComercial extends POIAttraction{
    
    protected ArrayList<Product> products;
    protected ArrayList<String> typesOfProductsSold;
    
    /**
     * Creates an POIComercial object and assigns its varaibles using data from the corrosponding ParsedObject.
     * @param pc the ParsedComercial object which contains data from the XML files which this object is based on.
     */
    
    public POIComercial(ParsedComercial pc)
    {
        super(pc.parsedAttractions);
        
        products = ObjectCreator.createArrayListWithProducts(pc.products);
        typesOfProductsSold = pc.typesOfProductsSold;
    }
    
    public String toString()
    {
        String s = super.toString();
        s += " products: ";
        for(int i = 0; i < products.size(); i++)
        {
            s += products.get(i) + ", "; 
        }
        s += " types of products: ";
        for(int i = 0; i < typesOfProductsSold.size(); i++)
        {
            s += typesOfProductsSold.get(i) + ", ";
        }
        
        return s;
    }
    
    public boolean hasProductNameWhichStartsWith(String s)
    {
        for(int i = 0; i < products.size(); i++)
        {
            if(products.get(i).getName().startsWith(s))
            {
                return true;
            }
        }
        return false;
    }
    
    public ArrayList<Product> getProducts()
    {
        return products;
    }
    public ArrayList<String> getTypesOfProductsSold()
    {
        return typesOfProductsSold;
    }
    
    public boolean hasProduct(Product p)
    {
        for(int i = 0; i < products.size(); i++)
        {
            if(products.get(i).equals(p))
            {
                return true;
            }
        }
        return false;
    }
    
    public boolean hasTypeOfProductSold(String s)
    {
        for(int i = 0; i < typesOfProductsSold.size(); i++)
        {
            if(typesOfProductsSold.get(i).equals(s))
            {
                return true;
            }
        }
        return false;
    }
    
    public boolean hasTypeOfProductSoldStartsWith(String s)
    {
        for(int i = 0; i < typesOfProductsSold.size(); i++)
        {
            if(typesOfProductsSold.get(i).startsWith(s))
            {
                return true;
            }
        }
        return false;
    }


}
